<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper" v-if="!singleProjected">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="项目名称">
              <a-input placeholder="请输入项目名称" v-model="queryParam.projectName"></a-input>
            </a-form-item>
          </a-col>
          <template>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="项目类型">
                <j-dict-select-tag
                  placeholder="请选择项目类型"
                  v-model="queryParam.projectType"
                  dictCode="sys_project_type"
                />
              </a-form-item>
            </a-col>
            <!--            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="标段（包）编号 - 电子招标投标系统技术规范 第1部分：交易平台技术规范 的附录b.3.5标段（包）编号">
                <a-input placeholder="请输入标段（包）编号 - 电子招标投标系统技术规范 第1部分：交易平台技术规范 的附录b.3.5标段（包）编号" v-model="queryParam.bidSectionCode"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="标段（包）名称">
                <a-input placeholder="请输入标段（包）名称" v-model="queryParam.bidSectionName"></a-input>
              </a-form-item>
            </a-col>-->
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>

              <!--              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>-->
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <slot name="actionList"></slot>
    <!-- 查询区域-END -->

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        class="j-table-force-nowrap"
        :scroll="{ x: true }"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange"
      >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <span slot="action" slot-scope="text, record">
          <template v-if="record.status == 0 || record.status == 3">
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
              <a>删除</a>
            </a-popconfirm>
            <a-divider type="vertical" />
            <a-popconfirm title="确定提交吗?" @confirm="() => handleSubmit(record)">
              <a>提交</a>
            </a-popconfirm>
            <a @click="handleEdit(record)" style="margin-left:10px">编辑</a>
          </template>
          <template v-else>
            <a @click="handleDetail(record)">详情</a>
          </template>
          <!-- <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown> -->
        </span>
      </a-table>
    </div>

    <ex-zbid-opening-arrange-modal ref="modalForm" @ok="modalFormOk" />
  </a-card>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ExZbidOpeningArrangeModal from './modules/ExZbidOpeningArrangeModal'
import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'
import { httpAction, getAction } from '@/api/manage'
import '@/assets/less/TableExpand.less'

export default {
  name: 'ExZbidOpeningArrangeList',
  mixins: [JeecgListMixin],
  components: {
    ExZbidOpeningArrangeModal,
  },
  props: { projectId: {} },
  data() {
    return {
      disableMixinCreated: true,
      superQueryParams: '',
      description: '场地预约管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title:'标段编号',
          align:"center",
          dataIndex: 'bidSectionCode'
        },
        {
          title:'标段名称',
          align:"center",
          dataIndex: 'bidSectionName'
        },
        {
          title: '项目编号',
          align: 'center',
          dataIndex: 'projectCode',
        },
        {
          title: '项目名称',
          align: 'center',
          dataIndex: 'projectName',
        },
        // {
        //   title: '项目类型',
        //   align: 'center',
        //   dataIndex: 'projectType_dictText',
        // },
        // {
        //   title:'监督部门名称',
        //   align:"center",
        //   dataIndex: 'superviseDeptName'
        // },
        // {
        //   title:'监督部门代码',
        //   align:"center",
        //   dataIndex: 'superviseDeptCode'
        // },
        {
          title: '开标室',
          align: 'center',
          dataIndex: 'bidOpeningAddress',
        },
        {
          title: '评标标室',
          align: 'center',
          dataIndex: 'biddingRoomName',
        },
        // {
        //   title:'监管单位',
        //   align:"center",
        //   dataIndex: 'government'
        // },
        // {
        //   title:'评标时间',
        //   align:"center",
        //   dataIndex: 'evaluationTime',
        //   customRender:function (text) {
        //     return !text?"":(text.length>10?text.substr(0,10):text)
        //   }
        // },
        // {
        //   title:'评标地点',
        //   align:"center",
        //   dataIndex: 'evaluationAddress'
        // },
        {
          title: '开标时间',
          align: 'center',
          dataIndex: 'bidOpeningTime'
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'status_dictText',
        },
        // {
        //   title:'交易系统标识码',
        //   align:"center",
        //   dataIndex: 'platformCode'
        // },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/exZbidOpeningArrange/exZbidOpeningArrange/list',
        delete: '/exZbidOpeningArrange/exZbidOpeningArrange/delete',
        deleteBatch: '/exZbidOpeningArrange/exZbidOpeningArrange/deleteBatch',
        exportXlsUrl: '/exZbidOpeningArrange/exZbidOpeningArrange/exportXls',
        importExcelUrl: 'exZbidOpeningArrange/exZbidOpeningArrange/importExcel',
        submitAudit: 'exZbidOpeningArrange/exZbidOpeningArrange/submitAudit',
      },
      dictOptions: {},
      superFieldList: [],
      singleProjected: false, //是否单个项目进入
    }
  },
  watch: {
    projectId: {
      immediate: true,
      handler(val) {
        if (val != '' && val != undefined) {
          this.singleProjected = true
        }
      },
    },
  },
  created() {
    let projectId = this.$route.query.projectId
    if (projectId) {
      this.disableMixinCreated = true
      this.superQueryParams = `[{field:'projectId',val:${projectId},dbType:'String',rule:'eq'}]`
      this.loadData()
    } else {
      this.loadData()
    }
    this.getSuperFieldList()
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    reloadList() {
      this.searchQuery()
      this.searchQuery()
    },
    initDictConfig() {},
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'fieldnameid', text: '场地安排标识码', dictCode: '' })
      fieldList.push({
        type: 'string',
        value: 'projectCode',
        text: '项目编号 - 电子招标投标系统技术规范 第1部分：交易平台技术规范 的附录b.3.2项目编号',
        dictCode: '',
      })
      fieldList.push({ type: 'string', value: 'projectName', text: '项目名称', dictCode: '' })
      fieldList.push({
        type: 'string',
        value: 'projectType',
        text: '项目类型 - 详见b.9.24项目类型',
        dictCode: 'sys_project_type',
      })
      fieldList.push({
        type: 'string',
        value: 'bidSectionCode',
        text: '标段（包）编号 - 电子招标投标系统技术规范 第1部分：交易平台技术规范 的附录b.3.5标段（包）编号',
        dictCode: '',
      })
      fieldList.push({ type: 'string', value: 'bidSectionName', text: '标段（包）名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'superviseDeptName', text: '监督部门名称', dictCode: '' })
      fieldList.push({
        type: 'string',
        value: 'superviseDeptCode',
        text: '监督部门代码 - 采用gb11714 -1997《全国组织机构代码编制规则》或gb 32100-2015 《法人和其他组织统一社会信用代码编码规则》',
        dictCode: '',
      })
      fieldList.push({ type: 'string', value: 'bidOpeningRoom', text: '开标房间', dictCode: '' })
      fieldList.push({ type: 'string', value: 'government', text: '监管单位', dictCode: '' })
      fieldList.push({ type: 'date', value: 'evaluationTime', text: '评标时间' })
      fieldList.push({ type: 'string', value: 'evaluationAddress', text: '评标地点', dictCode: '' })
      fieldList.push({ type: 'date', value: 'bidOpeningTime', text: '开标时间' })
      fieldList.push({ type: 'string', value: 'bidOpeningAddress', text: '开标地点', dictCode: '' })
      fieldList.push({
        type: 'string',
        value: 'platformCode',
        text: '交易系统标识码 - 交易平台机构的统一社会信用代码或组织机构代码',
        dictCode: '',
      })
      this.superFieldList = fieldList
    },
    handleSubmit(row) {
      var that = this
      httpAction(this.url.submitAudit + '?id=' + row.id, row, 'post')
        .then((res) => {
          if (res.success) {
            that.$message.success(res.message)
            that.loadData()
          } else {
            that.$message.warning(res.message)
          }
        })
        .finally(() => {
          that.confirmLoading = false
        })
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
